package cn.majingjing.demo.aop.controller;

import cn.majingjing.demo.aop.config.ScheduleConfig;
import org.springframework.scheduling.config.CronTask;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author JingjingMa
 * @date 2019/11/4 14:16
 */
@RestController
public class ScheduleController {


    @GetMapping("/get")
    public Object get(){
        ScheduledTaskRegistrar scheduledTaskRegistrar = ScheduleConfig.getScheduledTaskRegistrar();
        List<CronTask> cronTaskList = scheduledTaskRegistrar.getCronTaskList();
        return cronTaskList;
    }

    @PostMapping("/re-schedule")
    public void reSchedule(){
        ScheduleConfig.reScheduler();
    }

}
